package br.com.pizzaria.model.dao;

import org.hibernate.Query;
import org.hibernate.Session;

import br.com.pizzaria.hDAO.SessaoFactory;
import br.com.pizzaria.model.Usuario;

public class Autenticacao {

	private Session session;

	public Autenticacao() {
		session = SessaoFactory.getSessionFactory().getCurrentSession();
	}

	public boolean verificarDadosLogin(Usuario usuario) {
		String hql = "from Usuario where login = :ParamLogin and senha = :ParamSenha ";
		Query query = session.createQuery(hql);
		query.setParameter("ParamLogin", usuario.getLogin());
		query.setParameter("ParamSenha", usuario.getSenha());
		if (query.list().isEmpty()) {
			return false;
		}
		return true;
	}

}
